<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
            line-height: 100px;
            text-align: center;
            font-size: 20px;
        }
        .right {
            /* 使两个盒子为一排 */
            width: 300px;
            display: flex;
            background-color: white;
        }
        .box1 {
            /* 当margin-top为负数时,自身元素会向上移动 */
            margin-top: -50px;
        }
        .box2 {
            /* 当margin-left为负数时,自身元素会向左移动 */
            margin-left: -50px;
        }
        .box3 {
            /* 当margin-bottom为负数时,位于该元素下方的元素会向上移动 */
            margin-bottom: -50px;
        }
        .box4 {
            /* 当margin-right为负数时,位于该元素右侧的元素会向左移动 */
            margin-right: -50px;
        }
    </style>
</head>
<body>
    <!-- 当margin-top为负数时 -->
    <div class="box1">
        A
    </div>
    <!-- 当margin-left为负数时 -->
    <div class="box2">
        B
    </div>
    <!-- 当margin-bottom为负数时 -->
    <div class="box3">
        C
    </div>
    <div class="test-box3">
        test1
    </div>
    <!-- 当margin-right为负数时 -->
    <div class="right">
        <div class="box4">
            D
        </div>
        <div class="test-box4">
            test2
        </div>
    </div>
</body>
</html>